﻿<Controls:SinacorWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
    xmlns:Custom="http://schemas.xceed.com/wpf/xaml/datagrid"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"    
	xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"    
    Title="{DynamicResource Bovespa.Contabil.Label.CadastroDespesasNota}"
	x:Class="Sinacor.UI.Bovespa.Contabil.View.SmartClient.CadastroDespesaNota"
	AutoContentWidth="False"
    AutoContentHeight="False"
    ModuleId="BOL" 
    ModulePlus="False"
    WindowStartupLocation="CenterScreen"
    WindowState="Maximized">

    <Controls:SinacorExpanderContainer x:Name="ExpanderContainer" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="90"/>
            <RowDefinition Height="4" />
            <RowDefinition Height="*"/>
            <RowDefinition Height="4" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Contabil.Label.ExpanderPesquisa}"
                                  Grid.Row="0" 
                                  x:Name="expanderPesquisar"
                                  IsExpanded="True" 
                                  SnapsToDevicePixels="True">
            <Grid>
                <Controls:SinacorLabel Width="65"
                                       Content="{DynamicResource Bovespa.Contabil.Label.PesquisaHistCCCodigo}"
                                       Margin="0,0,0,0"
                                       HorizontalAlignment="Left"
                                       HorizontalContentAlignment="Left"/>
                <Controls:SinacorTextBox HorizontalAlignment="Left"
										 Margin="0,21,0,0" MaxLength="2"
                                         VerticalAlignment="Top"
                                         Width="40" x:Name="txtCodigo"
                                         Text="{Binding FiltroTipoDespesaPeriodo.Codigo}"
									     TabIndex="0"/>
                <Controls:SinacorLabel Width="70" 	
                                       Content="{DynamicResource Bovespa.Contabil.Label.PesquisaDescricao}"
                                       Margin="70,0,0,0" 	
                                       HorizontalAlignment="Left"
                                       HorizontalContentAlignment="Left"/>
                <Controls:SinacorTextBox HorizontalAlignment="Left"
                                         Margin="70,21,0,0"
                                         VerticalAlignment="Top" MaxLength="15"
                                         Width="310" x:Name="txtDescricao"
                                         Text="{Binding FiltroTipoDespesaPeriodo.Descricao}"
										 TabIndex="1"/>
                <Controls:SinacorLabel HorizontalAlignment="Left"
                                       Content="{DynamicResource Bovespa.Contabil.Label.PregaoInicial}"
                                       Width="109"
                                       Margin="384,0,0,0"
                                       HorizontalContentAlignment="Left"/>
                <Controls:SinacorDatePicker HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            TabIndex="2" x:Name="txtPregaoInicial"
                                            Value="{Binding FiltroTipoDespesaPeriodo.PregaoInicial}"
                                            Margin="384,21,0,0"/>
                <Controls:SinacorLabel HorizontalAlignment="Left"
                                       Content="{DynamicResource Bovespa.Contabil.Label.PregaoFinal}"
                                       Width="105"
                                       Margin="493,0,0,0"
                                       HorizontalContentAlignment="Left"/>
                <Controls:SinacorDatePicker HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            TabIndex="3" x:Name="txtPregaoFinal"
                                            Value="{Binding FiltroTipoDespesaPeriodo.PregaoFinal}"
                                            Margin="493,21,0,0"/>
                <Controls:SinacorButton Content="{DynamicResource Bovespa.Contabil.Label.BotaoPesquisar}"
                                        Width="85" x:Name="btnPesquisar"
                                        Margin="602,21,0,0"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Top"
                                        TabIndex="4" Click="btnPesquisar_Click"
                                        IsDefault="True"/>
                <Controls:SinacorButton x:Name="botaoNovaPesquisa"									
                                        IsEnabled="true"									
                                        Margin="691,21,0,0"									
                                        TabIndex="5" Click="botaoNovaPesquisa_Click"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Top"
                                        Width="106"
										Content="{DynamicResource Bovespa.Contabil.Label.BotaoNovaPesquisa}" />
            </Grid>
        </Controls:SinacorExpander>

        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Contabil.Label.ExpanderTipoDespesa}"
                                  Grid.Row="2"
                                  IsExpanded="True">
            <Grid>
                <Controls:SinacorDataGrid x:Name="dtgTipodespesa"
                                          Margin="0,0,0,0" HorizontalAlignment="Stretch"
                                          SelectionMode="Single" VerticalAlignment="Stretch" 
                                          ItemsSource="{Binding Path=cadastroDespesaNotaPresenter.ListaTipoDespesa, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}"
                                          SelectionChanged="dtgTipodespesa_SelectionChanged" 
                                          EndingInsert="dtgTipodespesa_EndingInsert"
                                          EndingUpdate="dtgTipodespesa_EndingUpdate"
                                          Deleting="dtgTipodespesa_Deleting"
                                          AllowBeginInsert="True" 
                                          AllowBeginUpdate="True" 
                                          MouseDoubleClick="dtgTipodespesa_MouseDoubleClick"
                                          AllowDelete="True">
                    <Controls:SinacorDataGrid.Columns>
                        <Controls:Column Name="Codigo" 			
                                         Title="Bovespa.Contabil.Label.CodigoTipoDespesa"
										 AutoAdjustWidthToContent="False"
										 Width="75"    			
                                         IsRequired="True" RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.CodigoTipoDespesaObrigatorio"
                                         AllowInsert="True" DisplayMemberPath="Codigo"			 
                                         AllowUpdate="False"
                                         HorizontalCellAlignment="Right">
                            <Controls:Column.CellInsertTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox Name="txtCodigo" Text="{Binding Codigo}" 
                                                       IsEnabled="true" MaxLength="2">
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellInsertTemplate>
                        </Controls:Column>
                        <Controls:Column Name="Descricao" 			
                                         Title="Bovespa.Contabil.Label.DescricaoTipoDespesa"
										 AutoAdjustWidthToContent="False"
										 Width="200" 
                                         IsRequired="True" 	RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.DescricaoTipoDespesaObrigatoria"
                                         AllowInsert="True" DisplayMemberPath="Descricao" 			
                                         AllowUpdate="True" 
                                         HorizontalCellAlignment="Left" CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox Name="txtDescricao" Text="{Binding Descricao}" 
                                                          IsEnabled="true" MaxLength="15">
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                    </Controls:SinacorDataGrid.Columns>
                </Controls:SinacorDataGrid>
            </Grid>
        </Controls:SinacorExpander>
        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Contabil.Label.ExpanderDespesaNota}"
                                  Grid.Row="4"
                                  IsExpanded="True">
            <Grid>
                <Controls:SinacorDataGrid x:Name="dtgDespesasNota"
                                          Margin="0,0,0,0"
                                          AllowBeginInsert="False" 
                                          AllowBeginUpdate="False" 
                                          AllowDelete="False"
                                          ItemsSource="{Binding Path=cadastroDespesaNotaPresenter.ListaDespesaNota, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}"
                                          SelectionMode="Single" IsEnabled="False"
                                          InsertEnded="dtgDespesasNota_InsertEnded"
                                          EndingInsert="dtgDespesasNota_EndingInsert"                                          
                                          EndingUpdate="dtgDespesasNota_EndingUpdate"
                                          Deleting="dtgDespesasNota_Deleting">

                    <Controls:SinacorDataGrid.Columns>
                        <Controls:Column Name="PregaoInicial" 			
                                         Title="Bovespa.Contabil.Label.PregaoInicial"
                                         AllowInsert="True"
                                         AllowUpdate="False"
										 AutoAdjustWidthToContent="False"
										 Width="110"
                                         DisplayMemberPath="PregaoInicial"
                                         HorizontalCellAlignment="Center"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDatePicker Name="txtPregaoInicial" Value="{Binding PregaoInicial}"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.PregaoInicialObrigatorio"
                                                            IsEnabled="true" >
                                    </Controls:SinacorDatePicker>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="PregaoFinal" 			
                                         Title="Bovespa.Contabil.Label.PregaoFinal"
                                         DisplayMemberPath="PregaoFinal"	 			
                                         AllowInsert="True" 			
                                         AllowUpdate="True"
										 AutoAdjustWidthToContent="False"
										 Width="110"			
                                         HorizontalCellAlignment="Center" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDatePicker Name="txtPregaoFinal" Value="{Binding PregaoFinal}"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.PregaoFinalObrigatorio"
                                                            IsEnabled="true">
                                    </Controls:SinacorDatePicker>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>


                        <Controls:Column Name="PorcDespesa" 			
                                         Title="Bovespa.Contabil.Label.PercDespesas"
                                         DisplayMemberPath="PercentualDespesa"		
                                         AllowInsert="True"  			
                                         AllowUpdate="True"
										 AutoAdjustWidthToContent="True"
                                         HorizontalCellAlignment="Right" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtPercentualDespesa" Value="{Binding PercentualDespesa}"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.PorcentagemObrigatoria"
                                                            Integers="2" Decimals="4" IsEnabled="true">
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="VlMinimo" 			
                                         Title="Bovespa.Contabil.Label.VlMinimo"
                                         DisplayMemberPath="ValorMinimo"		
                                         AllowInsert="True"			
                                         AllowUpdate="True" 		
                                         StringFormat="N2"
                                         HorizontalCellAlignment="Right"
                                         AutoAdjustWidthToContent="False"
                                         Width="95"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtValorMinimo" Value="{Binding ValorMinimo}"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.ValorMinimoObrigatorio"
                                                            Integers="10" Decimals="2" IsEnabled="true">
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="VlMaximo" 			
                                         DisplayMemberPath="ValorMaximo"		
                                         Title="Bovespa.Contabil.Label.VlMaximo"
                                         StringFormat="N2"
                                         AllowInsert="True" 			
                                         AllowUpdate="True"
                                         AutoAdjustWidthToContent="False"
                                         Width="95"
                                         HorizontalCellAlignment="Right" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtValorMaximo" Value="{Binding ValorMaximo}"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.ValorMaximoObrigatorio"
                                                            Integers="10" Decimals="2" IsEnabled="true">
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="SobreDesconto" 			
                                         Title="Bovespa.Contabil.Label.SobreDesconto"
                                         DisplayMemberPath="BaseDespesa"				
                                         AllowInsert="True" 			
                                         AllowUpdate="True"
										 AutoAdjustWidthToContent="False"
										 Width="130"		
                                         HorizontalCellAlignment="Left" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorComboBox  
                                        Name="cmbBaseDespesa"  
                                        VerticalAlignment="Top"
                                        MaxLength="25"
                                        ItemsSource="{Binding cadastroDespesaNotaPresenter.ListaTipoBaseDespesa, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}" 
                                        SelectedValue ="{Binding BaseDespesa}" 
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.BaseDespesaObrigatorio"                                        
                                        />
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="IncideIRRF" 			
                                         Title="Bovespa.Contabil.Label.IncideIRRF"
                                         DisplayMemberPath="IncideIrrf"
                                         AllowInsert="True"
                                         AllowUpdate="True"
										 AutoAdjustWidthToContent="True" 			
                                         HorizontalCellAlignment="Center" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorCheckBox x:Name="ckbIncideIRRF" IsChecked="{Binding IncideIrrf}"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="EventoContabil" 			
                                         Title="Bovespa.Contabil.Label.LabelEventoContabil"
                                         DisplayMemberPath="EventoContabil"					
                                         AllowInsert="True"  			
                                         AllowUpdate="True"  			
                                         HorizontalCellAlignment="Left"
										 AutoAdjustWidthToContent="False"
										 Width="200"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Controls:SinacorLabel Content="{Binding Path=EventoContabil.Codigo}"/>
                                        <Controls:SinacorLabel Content=" "/>
                                        <Controls:SinacorLabel Content="{Binding Path=EventoContabil.Descricao}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </Controls:Column.CellTemplate>

                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorComboBox  
                                        Name="cmbEventoContabil"  
                                        IsSynchronizedWithCurrentItem="False" 
                                        VerticalAlignment="Top"
                                        MaxLength="25"
                                        ItemsSource="{Binding cadastroDespesaNotaPresenter.ListaEventosContabeis, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}" 
                                        SelectedValue="{Binding Path=EventoContabil.Codigo}" 			
                                        SelectedValuePath="Codigo"
                                                            IsRequired="True" 
                                                            RequiredErrorMessage="Bovespa.Contabil.ExceptionMessage.InformeEventoContabil"                                        
                                        >
                                        <Controls:SinacorComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Controls:SinacorLabel Content="{Binding Path=Codigo}" Width="30"/>
                                                    <Controls:SinacorLabel Content=" "/>
                                                    <Controls:SinacorLabel Content="{Binding Path=Descricao}"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </Controls:SinacorComboBox.ItemTemplate>
                                    </Controls:SinacorComboBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                    </Controls:SinacorDataGrid.Columns>
                </Controls:SinacorDataGrid>
            </Grid>
        </Controls:SinacorExpander>

    </Controls:SinacorExpanderContainer>
</Controls:SinacorWindow>